home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / dayquote / dayquote.bas next >
BASIC Source File  |  1995-05-09  |  30KB  |  834 lines

  1.     DefInt A-Z
  2.  
  3.     CONST FALSE = 0
  4.     CONST TRUE = 1
  5.  
  6.     DECLARE SUB DoQuote (FileName$)
  7.     DECLARE SUB ParseCommandLine (Num%, Arg$())
  8.     DECLARE SUB PutQuote (Text$)
  9.     DECLARE SUB PrintDoc (FileName$)
  10.     DECLARE SUB ShowGimme ()
  11.     DECLARE SUB ShowHelp ()
  12.     DECLARE SUB ShowSyntax ()
  13.  
  14.     DIM ErrorString$(76): FOR j = 1 TO 76: READ ErrorString$(j): NEXT
  15.     Dim Arguments$(1 To 20)
  16.     Dim Shared QuoteText$(1 To 22)
  17.     Dim Shared ForeColor, BackColor, Justification
  18.     Dim Shared StartCol, EndCol, TopLine, WipeScreen
  19.  
  20.     PRINT
  21.    
  22.     CALL ParseCommandLine(NumArgs%, Arguments$())
  23.  
  24.     IF Arguments$(1) = "" THEN ShowSyntax
  25.  
  26.     FOR i = 1 TO NumArgs%
  27.         SELECT CASE LEFT$(Arguments$(i), 2)
  28.         CASE "/?"
  29.             ShowHelp
  30.         CASE "/F"
  31.             IF MID$(Arguments$(i), 3, 1) = ":" THEN
  32.                 ExpectedArg$ = MID$(Arguments$(i), 4, LEN(Arguments$(i)))
  33.                 SELECT CASE ExpectedArg$
  34.                 CASE "BLACK", "BLK"
  35.                     ForeColor% = 1
  36.                 CASE "BLUE", "BLU"
  37.                     ForeColor% = 2
  38.                 CASE "GREEN", "GRN"
  39.                     ForeColor% = 3
  40.                 CASE "CYAN", "CYA"
  41.                     ForeColor% = 4
  42.                 CASE "RED"
  43.                     ForeColor% = 5
  44.                 CASE "MAGENTA", "MAG"
  45.                     ForeColor% = 6
  46.                 CASE "BROWN", "BRN"
  47.                     ForeColor% = 7
  48.                 CASE "WHITE", "WHT"
  49.                     ForeColor% = 8
  50.                 CASE "GRAY", "GREY", "GRY"
  51.                     ForeColor% = 9
  52.                 CASE "LTBLUE", "LBL"
  53.                     ForeColor% = 10
  54.                 CASE "LTGREEN", "LGR"
  55.                     ForeColor% = 11
  56.                 CASE "LTCYAN", "LCY"
  57.                     ForeColor% = 12
  58.                 CASE "LTRED", "LRD"
  59.                     ForeColor% = 13
  60.                 CASE "LTMAGENTA", "LMG"
  61.                     ForeColor% = 14
  62.                 CASE "YELLOW", "YEL"
  63.                     ForeColor% = 15
  64.                 CASE "BRWHITE", "BRW"
  65.                     ForeColor% = 16
  66.                 CASE ELSE
  67.                     CommandError = TRUE
  68.                     PRINT "Invalid foreground specification:  "; ExpectedArg$
  69.                 END SELECT
  70.                 ExpectedArg$ = ""
  71.             ELSE
  72.                 CommandError = TRUE
  73.                 PRINT "Missing colon in switch:  "; Arguments$(i)
  74.             END IF
  75.         CASE "/B"
  76.             IF MID$(Arguments$(i), 3, 1) = ":" THEN
  77.                 ExpectedArg$ = MID$(Arguments$(i), 4, LEN(Arguments$(i)))
  78.                 SELECT CASE ExpectedArg$
  79.                 CASE "BLACK", "BLK"
  80.                     BackColor% = 1
  81.                 CASE "BLUE", "BLU"
  82.                     BackColor% = 2
  83.                 CASE "GREEN", "GRN"
  84.                     BackColor% = 3
  85.                 CASE "CYAN", "CYA"
  86.                     BackColor% = 4
  87.                 CASE "RED"
  88.                     BackColor% = 5
  89.                 CASE "MAGENTA", "MAG"
  90.                     BackColor% = 6
  91.                 CASE "BROWN", "BRN"
  92.                     BackColor% = 7
  93.                 CASE "WHITE", "WHT"
  94.                     BackColor% = 8
  95.                 CASE "GRAY", "GREY", "GRY"
  96.                     BackColor% = 9
  97.                 CASE "LTBLUE", "LBL"
  98.                     BackColor% = 10
  99.                 CASE "LTGREEN", "LGR"
  100.                     BackColor% = 11
  101.                 CASE "LTCYAN", "LCY"
  102.                     BackColor% = 12
  103.                 CASE "LTRED", "LRD"
  104.                     BackColor% = 13
  105.                 CASE "LTMAGENTA", "LMG"
  106.                     BackColor% = 14
  107.                 CASE "YELLOW", "YEL"
  108.                     BackColor% = 15
  109.                 CASE "BRWHITE", "BRW"
  110.                     BackColor% = 16
  111.                 CASE ELSE
  112.                     CommandError = TRUE
  113.                     PRINT "Invalid background specification:  "; ExpectedArg$
  114.                 END SELECT
  115.                 ExpectedArg$ = ""
  116.             ELSE
  117.                 CommandError = TRUE
  118.                 PRINT "Missing colon in switch:  "; Arguments$(i)
  119.             END IF
  120.         CASE "/L"
  121.             IF LEN(Arguments$(i)) = 2 THEN
  122.                 IF NOT (Justification) THEN
  123.                     Justification = 1
  124.                 ELSE
  125.                     CommandError = TRUE
  126.                     PRINT "Multiple text justifications are not allowed:  "; Arguments$(i)
  127.                 END IF
  128.             ELSE
  129.                 CommandError = TRUE
  130.                 PRINT "Invalid switch:  "; Arguments$(i)
  131.             END IF
  132.         CASE "/C"
  133.             IF LEN(Arguments$(i)) = 2 THEN
  134.                 IF NOT (Justification) THEN
  135.                     Justification = 2
  136.                 ELSE
  137.                     CommandError = TRUE
  138.                     PRINT "Multiple text justifications are not allowed:  "; Arguments$(i)
  139.                 END IF
  140.             ELSE
  141.                 CommandError = TRUE
  142.                 PRINT "Invalid switch:  "; Arguments$(i)
  143.             END IF
  144.         CASE "/R"
  145.             IF LEN(Arguments$(i)) = 2 THEN
  146.                 IF NOT (Justification) THEN
  147.                     Justification = 3
  148.                 ELSE
  149.                     CommandError = TRUE
  150.                     PRINT "Multiple text justifications are not allowed:  "; Arguments$(i)
  151.                 END IF
  152.             ELSE
  153.                 CommandError = TRUE
  154.                 PRINT "Invalid switch:  "; Arguments$(i)
  155.             END IF
  156.         CASE "/S"
  157.             IF MID$(Arguments$(i), 3, 1) = ":" THEN
  158.                 ExpectedArg = VAL(MID$(Arguments$(i), 4, LEN(Arguments$(i))))
  159.                 IF (ExpectedArg > 0) AND (ExpectedArg < 31) THEN
  160.                     StartCol = ExpectedArg
  161.                 ELSE
  162.                     CommandError = TRUE
  163.                     PRINT "Invalid starting column:  "; MID$(Arguments$(i), 4, LEN(Arguments$(i)))
  164.                 END IF
  165.                 ExpectedArg = 0
  166.             ELSE
  167.                 CommandError = TRUE
  168.                 PRINT "Missing colon in switch:  "; Arguments$(i)
  169.             END IF
  170.         CASE "/E"
  171.             IF MID$(Arguments$(i), 3, 1) = ":" THEN
  172.                 ExpectedArg = VAL(MID$(Arguments$(i), 4, LEN(Arguments$(i))))
  173.                 IF (ExpectedArg > 49) AND (ExpectedArg < 81) THEN
  174.                     EndCol = ExpectedArg
  175.                 ELSE
  176.                     CommandError = TRUE
  177.                     PRINT "Invalid ending column:  "; MID$(Arguments$(i), 4, LEN(Arguments$(i)))
  178.                 END IF
  179.                 ExpectedArg = 0
  180.             ELSE
  181.                 CommandError = TRUE
  182.                 PRINT "Missing colon in switch:  "; Arguments$(i)
  183.             END IF
  184.         CASE "/T"
  185.             IF MID$(Arguments$(i), 3, 1) = ":" THEN
  186.                 ExpectedArg = VAL(MID$(Arguments$(i), 4, LEN(Arguments$(i))))
  187.                 IF (ExpectedArg > 0) AND (ExpectedArg < 25) THEN
  188.                     TopLine = ExpectedArg
  189.                 ELSE
  190.                     CommandError = TRUE
  191.                     PRINT "Invalid top line:  "; MID$(Arguments$(i), 4, LEN(Arguments$(i)))
  192.                 END IF
  193.                 ExpectedArg = 0
  194.             ELSE
  195.                 CommandError = TRUE
  196.                 PRINT "Missing colon in switch:  "; Arguments$(i)
  197.             END IF
  198.         CASE "/W"
  199.             IF LEN(Arguments$(i)) = 2 THEN
  200.                 WipeScreen = TRUE
  201.             ELSE
  202.                 CommandError = TRUE
  203.                 PRINT "Invalid switch:  "; Arguments$(i)
  204.             END IF
  205.         CASE "/$"
  206.             IF CommandError = FALSE THEN
  207.                 IF LEN(Arguments$(i)) = 2 THEN
  208.                     ShowGimme
  209.                 ELSE
  210.                     CommandError = TRUE
  211.                     PRINT "Invalid switch:  "; Arguments$(i)
  212.                 END IF
  213.             END IF
  214.         CASE "/D"
  215.             ON ERROR GOTO PrintDocError
  216.             IF CommandError = FALSE THEN
  217.                 IF MID$(Arguments$(i), 3, 1) = ":" THEN
  218.                     FileNa